package com.work.xxzl.module.pagemessage;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.work.xxzl.R;
import com.work.xxzl.utils.UIUtils;
import com.hyphenate.chat.EMMessage;
import com.hyphenate.easeui.EaseConstant;
import com.hyphenate.easeui.ui.EaseChatFragment;
import com.hyphenate.easeui.widget.chatrow.EaseCustomChatRowProvider;

/**
 * author: Aly
 * date :2018/11/12 14:17
 * version:1.0
 * description:继承 EaseChatFragment 实现会话页面
 */
public class MyEaseChatFragment extends EaseChatFragment {

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        fragmentArgs = getArguments();
        // check if single chat or group chat
        chatType = fragmentArgs.getInt(EaseConstant.EXTRA_CHAT_TYPE, EaseConstant.CHATTYPE_SINGLE);
        // userId you are chat with or group id
        toChatUsername = fragmentArgs.getString(EaseConstant.EXTRA_USER_ID);//传递过来的发送者的ID
    }

    @Override
    protected void setUpView() {
        super.setUpView();
        titleBar.setRightImageResource(R.drawable.qunmessage);
        titleBar.setRightLayoutClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                Intent intent = new Intent(getContext(), QunDetailActiovity.class);
//                intent.putExtra("username", toChatUsername);
//                UIUtils.startActivity(intent);
            }
        });
        setChatFragmentHelper(new EaseChatFragmentHelper() {
            /**
             * 设置消息扩展属性
             */
            @Override
            public void onSetMessageAttributes(EMMessage message) {

            }

            /**
             * 进入会话详情
             */
            @Override
            public void onEnterToChatDetails() {

            }

            /**
             * 用户头像点击事件
             * @param username
             */
            @Override
            public void onAvatarClick(String username) {
//                Intent intent = new Intent(getContext(), FriendDetailActivity.class);
//                intent.putExtra("username", username);
//                UIUtils.startActivity(intent);
            }

            @Override
            public void onAvatarLongClick(String username) {

            }

            /**
             * 消息气泡框点击事件
             */
            @Override
            public boolean onMessageBubbleClick(EMMessage message) {
                return false;
            }

            @Override
            public void onMessageBubbleLongClick(EMMessage message) {

            }

            /**
             * 扩展输入栏item点击事件,如果要覆盖EaseChatFragment已有的点击事件，return true
             * @param view
             * @param itemId
             * @return
             */
            @Override
            public boolean onExtendMenuItemClick(int itemId, View view) {
                return false;
            }

            /**
             * 设置自定义chatrow提供者
             * @return
             */
            @Override
            public EaseCustomChatRowProvider onSetCustomChatRowProvider() {
                return null;
            }
        });
    }

}
